﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Logic.Utils
{
	public class WebUtils
	{

		public class Web
		{
			public static string CreateUrl(string schema, string authority, string path)
			{
				return schema + "://" + authority + path;
			}

			public static string AddParameterToUrl(string url, string parameter)
			{
				if (!url.Contains('?'))
					url += '?';
				else
				{
					if (!url.EndsWith("?") && !url.EndsWith("&"))
						url += '&';
				}

				return url + parameter;
			}

			#region Cookies

			public static void ClearCookie(string cookieName)
			{
				HttpContext.Current.Request.Cookies.Remove(cookieName);
			}

			public static void ModifyCookie(HttpCookie modifiedCookie)
			{
				ClearCookie(modifiedCookie.Name);
				HttpContext.Current.Response.Cookies.Add(modifiedCookie);
			}

			public static void ModifyCookie(string cookieName, HttpCookie modifiedCookie)
			{
				ClearCookie(cookieName);
				HttpContext.Current.Response.Cookies.Add(modifiedCookie);
			}

			#endregion
		}
	}
}
